var width;
var height;
const innerAudioContext = wx.createInnerAudioContext()
//获取用户手机长度与宽度信息，自定适应不同手机
wx.getSystemInfo({
  success: function (res) {
    width = res.windowWidth;
    height = res.windowHeight;
  }
});
var controlRight = parseInt(width) * 0.1;
var app = getApp();
Page({
  data: {
    phone: '',
    scale: 15,
    longitude: '',
    latitude: '',
    width: width,
    height: height,
    polyline: [
      {
        points: [],
        color: "#00ff00",
        width: 6,
        arrowLine: true
      }
    ]

  },
  onLoad: function (options) {
    var that = this
    var polyline = this.data.polyline
    wx.request({
      url: app.appData.contextPath + 'findOneMessageLatlonSetvlet',
      data: {
        phone: app.appData.systemUser.phone,
        id: options.id
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        var latlonArray = res.data;
        console.log(res.data)
        var polyline = that.data.polyline
        for (var i = 0; i < latlonArray.length && i < 2; i++) {
          polyline[0].points = latlonArray[i].locations
        }
        that.setData({
          polyline: polyline
        });
      },
      fail:function(){
        console.log('fail')
      }
    })

  },
  onShow: function () { },

  onReady: function () {
    var that = this
    var status = app.appData.systemUser.status;


    var that = this;
    wx.getLocation({
      type: 'gcj02',
      //返回可以用于wx.openLocation的经纬度
      success: function (res) {
        that.setData({
          latitude: res.latitude,
          longitude: res.longitude,
        })
      }
    });
  },


})
